package study.config.apollo.controller;

import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import study.eggs.result.Result;
import study.eggs.result.Results;

import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/config")
public class _01_ValueController {

    @Value("${name:gaga}")
    private String name;
    @Value("${age:30}")
    private int age;

    @RequestMapping("/config/value")
    public Result value() {
        Map<String, Object> data = Maps.newHashMap();
        data.put("name", name);
        data.put("age", age);
        return Results.ok(data);
    }
}
